package com.zzq.service.impl;

import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.zzq.annotation.EnableMyPage;
import com.zzq.domain.dto.SmileShootAddressApplyDTO;

import com.zzq.domain.entity.SmileShootAddressApply;
import com.zzq.domain.search.ShootAddressApplySearchParamet;
import com.zzq.enumerate.AuditEnum;
import com.zzq.result.SmileResult;
import com.zzq.service.ShootAdressApplyAdminService;
import com.zzq.service.SmileShootAddressApplyService;
import com.zzq.util.ObjectUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ShootAdressApplyAdminServiceImpl implements ShootAdressApplyAdminService {
    @Autowired
    SmileShootAddressApplyService shootAddressApplyService;
    @Override
    @EnableMyPage
    public SmileResult getShootAdressApplylist(ShootAddressApplySearchParamet searchParamet) {
        List<SmileShootAddressApplyDTO> list = shootAddressApplyService.getShootAddressApplyDTO(searchParamet);
        return SmileResult.sucess("获取成功",list);
    }

    @Override
    public SmileResult delShootAdressApplyById(Long shootAddressApplyId) {
        shootAddressApplyService.removeById(shootAddressApplyId);
        return  SmileResult.sucess("删除成功");
    }

    @Override
    public SmileResult setAudit(Long shootAddressApplyId, Boolean isby) {
        LambdaUpdateWrapper<SmileShootAddressApply> queryWrapper = new LambdaUpdateWrapper();
        queryWrapper.eq(
                !ObjectUtils.isEmpty(shootAddressApplyId),
                SmileShootAddressApply::getId,
                shootAddressApplyId);
        if (isby) {
            queryWrapper.set(SmileShootAddressApply::getAudit, AuditEnum.AUDITED.getName());
        } else {
            queryWrapper.set(SmileShootAddressApply::getAudit, AuditEnum.NOAUDITED.getName());
        }
        shootAddressApplyService.update(queryWrapper);
        return SmileResult.sucess("审核成功");
    }
}
